1、将下面内容存为文件test.py后执行即可。(执行前需要安装python脚本解析器,下载地址http://www.python.org/getit/)
2、可以调用命令行将下面代码拷贝到命令行执行即可。
import urllib2
import reurl = 'http://192.168.1.192'
content = urllib2.urlopen(url).read()
file = open('results.txt','w')
file.write(str(content))
file.close
pattern1 = re.findall(r'alert\(\"(.*)\"\)',content)
for i in pattern1:
print i
print 'hello world!\n'
sub1 = re.sub(r'alert\(\"(.*)\"\)','Hello World!',content)
#print sub1